<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 使用原生js的递归函数实现深拷贝
        function deepCopy(data) {
            if (getType(data) == 'Array') {
                var res = [];
            } else if (getType(data) == 'Object') {
                var res = {};
            } else {
                return data;
            }
            for (var key in data) {
                if (getType(data[key]) == 'Array' || getType(data[key]) == 'Object') {
                    res[key] = deepCopy(data[key]);
                } else {
                    res[key] = data[key];
                }
            }
            return res;
        }

        function getType(data) {
            return Object.prototype.toString.call(data).slice(8, -1);
        }
    </script>
</body>

</html>